package Day02;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

/**
 * @author feng
 * @Date 2022/1/1 21:32
 * 字符串的定义方式
 */
public class Day01 {
    public static void main(String[] args) {
        String s = "abc";
        System.out.println(s.indexOf("a"));
        String s1 = new String("abc");
        System.out.println(s);
        System.out.println(s1);
        System.out.println(s.equals(s1));
        //常用方法
        char c = s.charAt(0);
        System.out.println("下标为0:" + c);
        System.out.println("长度" + s.length());
        //劫串，末尾不包含
        String substring = s.substring(0, 2);
        System.out.println("子串:" + substring);
        try {
            byte[] bytes = s.getBytes("utf-8");
            for (Byte b : bytes) {
                System.out.println(b);
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
